package cn.admin.configcenter.registry;

import cn.admin.configcenter.registry.service.DataService;
import cn.admin.configcenter.registry.service.PushDataService;
import cn.admin.configcenter.registry.service.client.*;
import cn.admin.configcenter.registry.service.push.DefaultPushService;

public class IOCFactory {

    private static final ConfigServerConnectionFactory CONFIG_SERVER_CONNECTION_FACTORY =
            new ConfigServerConnectionFactory();
    private static final NonPersistDataMerge NON_PERSIST_DATA_MERGE = new NonPersistDataMerge();
    private static final DataService DATA_SERVICE;
    private static final ClientManager CLIENT_MANAGER;
    private static final PushDataService PUSH_DATA_SERVICE;

    public static ConfigServerConnectionFactory getConfigServerConnectionFactory() {
        return CONFIG_SERVER_CONNECTION_FACTORY;
    }

    public static DataService getDataService() {
        return DATA_SERVICE;
    }

    public static ClientManager getClientManager() {
        return CLIENT_MANAGER;
    }

    public static PushDataService getPushDataService() {
        return PUSH_DATA_SERVICE;
    }

    static {
        DATA_SERVICE = new DefaultDataService(NON_PERSIST_DATA_MERGE);
        CLIENT_MANAGER = new DefaultClientManager(DATA_SERVICE);
        PUSH_DATA_SERVICE = new DefaultPushService();
    }

}
